using UnityEngine;
using Framework;
using Framework.Scene;
using Cinemachine;

namespace Game
{
    public sealed class FightScene : BaseScene
    {
        [SerializeField]
        private CinemachineFreeLook m_ThirdPersonCamera;
        public CinemachineFreeLook ThirdPersonCamera { get { return m_ThirdPersonCamera; } }

        public override void OnCreateScene()
        {
            Log.Info("[FightScene] OnCreateScene");
            this.LoadResource().Coroutine();
        }

        private async FVoid LoadResource()
        {
            await GameEntry.UI.OpenUI(AssetUtility.GetUIPath("Fight/FightPanel"));
            this.LoadingPanel.RefreshLoadingProgress(0.5f);
            await GameEntry.Fight.InitFight();
            this.LoadingPanel.RefreshLoadingProgress(1.0f);
        }

        public override void OnEnterScene()
        {
            Log.Info("[FightScene] OnEnterScene");
            GameEntry.Fight.StartFight();
        }

        public override void OnLeaveScene()
        {
            Log.Info("[FightScene] OnLeaveScene");
            GameEntry.Fight.LeaveFight();
            GameEntry.UI.CloseUI(typeof(FightPanel));
        }
    }
}